--*-----------------------------------------------------------------------------
--
-- ALBUM_ITEM
--
--*-----------------------------------------------------------------------------
IF NOT EXISTS(
  SELECT 1
    FROM information_schema.tables
   WHERE table_name = 'ALBUM_ITEM'
)
BEGIN
  CREATE TABLE ALBUM_ITEM
  (
    ID INT IDENTITY(1,1) NOT NULL
  , URL NVARCHAR(MAX) NOT NULL
  , ALBUM_ID INT NOT NULL
  , DESCRIPTION NVARCHAR(MAX)
  )
  ALTER TABLE ALBUM_ITEM ADD CONSTRAINT PK_ALBUM_ITEM PRIMARY KEY(ID)
  ALTER TABLE ALBUM_ITEM ADD CONSTRAINT FK_ALBUM_ITEM_ALBUM FOREIGN KEY (ALBUM_ID) REFERENCES ALBUM(ID) ON DELETE CASCADE
  CREATE INDEX IDX_ALBUM_ITEM_ALBUM ON ALBUM_ITEM(ALBUM_ID)
END
GO
